# Author:wangfangfang

from selenium import webdriver
from selenium.webdriver.support.select import Select
from common.login import Login
import time,random
class StudentInfo:

    def __init__(self):

       self.driver = Login('超级管理员').login()




    # def login_in(self,username,password):
    #
    #
    #     self.wd.find_element_by_name("userName").send_keys(username)
    #
    #     self.wd.find_element_by_name("userPass").send_keys(password)
    #
    #
    #     self.wd.find_element_by_name("checkcode").send_keys(checkcode)
    #     self.wd.find_element_by_xpath('//button[@onclick="login();"]').click()
    def studentInfo(self):
        self.driver.find_element_by_link_text('学员管理').click()
        self.driver.find_element_by_link_text('学员信息').click()

    def region(self):
        select_options = Select(self.driver.find_element_by_name('region')).options
        rand = random.randint(0, len(select_options) - 1)
        S = Select(self.driver.find_element_by_name('region')).select_by_index(rand)

    def orientation(self):
        select_options = Select(self.driver.find_element_by_name('orientation')).options
        rand = random.randint(0, len(select_options) - 1)
        S = Select(self.driver.find_element_by_name('orientation')).select_by_index(rand)

    def stuclass(self):
        select_options = Select(self.driver.find_element_by_name('stuClass')).options
        rand = random.randint(0, len(select_options) - 1)
        S = Select(self.driver.find_element_by_name('stuClass')).select_by_index(rand)

    def stustatus(self):
        select_options = Select(self.driver.find_element_by_name('stuStatus')).options
        rand = random.randint(0, len(select_options) - 1)
        S = Select(self.driver.find_element_by_name('stuStatus')).select_by_index(rand)

    def stuname(self,studentname):
        self.driver.find_element_by_name('stuName').send_keys(studentname)
        time.sleep(2)
        self.driver.find_element_by_xpath('//*[@id="stuInfo"]/div[1]/button').click()


        time.sleep(10)
        self.driver.quit()

if __name__ == '__main__':

    a = StudentInfo()
    a.studentInfo()
    a.stuclass()
